package worldcount

import scala.io.Source

/**
  * Created by zx on 2018/5/3.
  */
object WorldCountFromFile {

  def main(args: Array[String]): Unit = {
    val lines = Source.fromURL(getClass.getResource("/The_man_of_property.txt")).getLines().toList
    val res = lines.flatMap(_.split(" ")).map((_, 1)).groupBy(_._1).map(t=>(t._1, t._2.size)).toList.sortBy(_._2).reverse.take(20)
    println(res)
  }
}
